.title_wrapper
  %h2 Utilities: Bundles

%h3
  = h @bundles.name
      
.form_view

  %h4
    Edit Bundle Details

  - form_for(@bundles) do |f|
    = f.error_messages
    %p
      = f.label :name
      %br
      = f.text_field :name
    %p
      = f.label :description
      %br
      = f.text_area :description
    %p
      =f.label :publications
      .select
        = select_tag "publications_out", options_from_collection_for_select(@publications_out, :id, :name), {:multiple => true, :id => 's1'}
        / = f.collection_select :publication_ids, @publications, :id, :name, {}, {:multiple => true, :id => 's1'}
        %br
        %a#addToSel.hand
          Add
      .select
        = f.collection_select :publication_ids, @publications_in, :id, :name, {}, {:multiple => true, :id => 's2'}
        %br
        %a#removeSel.hand
          Remove
    %br{:clear => 'all'}
    %br
    %p
      = f.label :status
      %br
      = f.select :status, @statuses, :include_blank => true
    %p
    - times_build = BundleVariation.frequency.length - @bundles.bundle_variations.count
    - times_build.times {@bundles.bundle_variations.build}
    
    - @bundles.bundle_variations.each do |g| 
      - g.build_trial_period if g.trial_period.nil?

    = render :partial => 'bundle_variations/add_form', :locals => {:f => f}
    %p
    %br{:clear => 'all'}
    = f.submit 'Update'

= link_to 'Show', @bundles
|
= link_to 'Back', bundles_path